# -*- coding: utf-8 -*-
# https://blog.csdn.net/weixin_52040868
# 公众号：测个der
# 微信：qing_an_an

import sys
from PyQt5.QtWidgets import QApplication  ,QWidget , QPushButton,QHBoxLayout,QVBoxLayout

class Winform(QWidget):
    def __init__(self,parent=None):
        super(Winform,self).__init__(parent)
        self.resize(1000,500)
        btn1 = QPushButton(self)
        btn2 = QPushButton(self)
        btn3 = QPushButton(self)

        btn1.setText("1")
        btn2.setText("2")
        btn3.setText("3")

        """
        在所有addWidget前添加一个伸缩控件，则所有控件居右显示
        在所有addWidget后添加一个伸缩控件，则所有控件居左显示
        """
        box = QHBoxLayout()
        box.addWidget(btn1)
        box.addStretch(0)

        box.addWidget(btn2)
        box.addStretch(1)

        box.addWidget(btn3)
        box.addStretch(1)


        self.setLayout(box)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    form = Winform()
    form.show()
    sys.exit(app.exec_())